﻿

Public Class ZipperFormPanel

    'Design Zip Creation Event :
    Private Sub ZD_ZipCreationRequested(sender As Object, e As ZipCreationRequestedEventArgs) Handles ZD.ZipCreationRequested
        Me.SuspendLayout()
        ZD.Visible = False
        ZPV.Visible = True
        ZPV.BringToFront()
        ZPV.CreateZip(e.Location, ZD.Setter.PF.Filters)
        Me.ResumeLayout()
    End Sub
    'Progress Events :
    Private Sub ZPV_ProgressAbortRequired(sender As Object, e As System.EventArgs) Handles ZPV.ProgressAbortRequired
        RaiseEvent ZipCreationAbortRequested(Me, e)
    End Sub
    Private Sub ZPV_ProgressCancelRequired(sender As Object, e As System.EventArgs) Handles ZPV.ProgressCancelRequired
        Me.SuspendLayout()
        ZD.Visible = True
        ZD.Designer.SelectNode(ZD.Designer.RootZipNode)
        ZD.Designer.KHG.ValuesPrimary.Description = ""
        ZPV.Visible = False
        ZD.BringToFront()
        Me.ResumeLayout()
    End Sub
    Private Sub ZPV_ProgressSavingError(sender As Object, e As ZipSavingErrorOccuredEventArgs) Handles ZPV.ProgressSavingError
        Me.SuspendLayout()
        KryptonMessageBox.Show("Zip Creation Error Occured : " & vbNewLine & e.OccuredError.Message, _
                               "Zipper - Error", _
                               MessageBoxButtons.OK, MessageBoxIcon.Error)
        ZD.Designer.SelectNode(ZD.Designer.RootZipNode)
        ZD.Designer.KHG.ValuesPrimary.Description = ""
        ZD.Visible = True
        ZPV.Visible = False
        ZD.BringToFront()
        Me.ResumeLayout()
    End Sub
    Private Sub ZPV_ProgressSavingFinished(sender As Object, e As ZipSavingFinishedEventArgs) Handles ZPV.ProgressSavingFinished
        Dim temps As List(Of String) = ZD.Designer.TempsLocations
        For Each Loc As String In temps
            IO.Directory.Delete(Loc, True)
        Next
        RaiseEvent ZipCreationFinished(Me, e)
    End Sub
    Public Event ZipCreationAbortRequested As EventHandler(Of EventArgs)
    Public Event ZipCreationFinished As EventHandler(Of EventArgs)

    Public Property SettingsEnabled As Boolean
        Get
            Return ZD.SettingsEnabled
        End Get
        Set(value As Boolean)
            ZD.SettingsEnabled = value
        End Set
    End Property
    Public Property SettingsVisible As Boolean
        Get
            Return ZD.SettingsVisible
        End Get
        Set(value As Boolean)
            ZD.SettingsVisible = value
        End Set
    End Property

End Class
